Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/PacketHandler.kt 4d4070c8e1ed73a56ee2f054300a0f62e3fe2e62 (4d4070c8) Text, 4.36 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.repository

Tff7b72import T7ee787org.meshtastic.proto.MeshPacket
Tff7b72import T7ee787org.meshtastic.proto.QueueStatus
Tff7b72import T7ee787org.meshtastic.proto.ToRadio

T8b949e/** Interface for handling the transmission of packets to the radio and managing the packet queue. */
Tff7b72interface T56d364PacketHandler Tb4b4b4{
T8b949e/** Sends a command/packet directly to the radio. */
Tff7b72fun Td2a8ffsendToRadioTb4b4b4(Te6edf3pTb4b4b4: Te6edf3ToRadioTb4b4b4)

T8b949e/**
* Adds a mesh packet to the queue for sending.
*
* A completed packet ID may be reused by a later retry. A duplicate is rejected only while that ID is still queued
* or in flight, preserving single ownership of its response.
*
* @return `true` when the packet's non-zero ID was reserved and queued, or `false` when the packet was invalid, its
* ID was already reserved, the radio is not connected, or the owning service scope has shut down.
*/
Tff7b72suspend Tff7b72fun Td2a8ffsendToRadioTb4b4b4(Te6edf3packetTb4b4b4: Te6edf3MeshPacketTb4b4b4)Tb4b4b4: Tffa657Boolean

T8b949e/**
* Adds [packet] only while [expectedConnectionVersion] still owns the connected lifecycle generation.
*
* This is the admission path for work captured by a specific connection and closes the check-then-send race across
* disconnect/reconnect.
*
* @return `true` when the expected generation is still current and the packet is admitted, or `false` when the
* generation is stale or admission fails for any reason documented by [sendToRadio].
*/
Tff7b72suspend Tff7b72fun Td2a8ffsendToRadioForConnectionTb4b4b4(Te6edf3packetTb4b4b4: Te6edf3MeshPacketTb4b4b4, Te6edf3expectedConnectionVersionTb4b4b4: Tffa657LongTb4b4b4)Tb4b4b4: Tffa657Boolean

T8b949e/**
* Adds a mesh packet to the queue and suspends until its routing acknowledgement arrives.
*
* A successful [QueueStatus] only means that firmware accepted the packet into its transport queue; it does not
* prove that a self-addressed admin command has been processed. This stricter acknowledgement is required when a
* later packet depends on that command, such as installing a shared contact before sending the first DM.
*
* Time spent behind packets already in the FIFO is not part of the response timeout. The timeout begins after an
* active transport admits this packet and ends on its routing ACK/NAK or synchronous local-loopback result.
*
* @return `true` on a routing ACK or synchronous local-loopback delivery (`ERRNO_SHOULD_RELEASE`); `false` when
* disconnected, transport sending fails, a routing NAK or queue rejection arrives, or the operation times out.
*/
Tff7b72suspend Tff7b72fun Td2a8ffsendToRadioAndAwaitTb4b4b4(Te6edf3packetTb4b4b4: Te6edf3MeshPacketTb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72= Te6edf3sendToRadioAndAwaitResultTb4b4b4(Te6edf3packetTb4b4b4)Tb4b4b4.Te6edf3accepted

T8b949e/** Detailed form of [sendToRadioAndAwait], including whether an active transport admitted the packet. */
Tff7b72suspend Tff7b72fun Td2a8ffsendToRadioAndAwaitResultTb4b4b4(Te6edf3packetTb4b4b4: Te6edf3MeshPacketTb4b4b4)Tb4b4b4: Te6edf3AwaitedSendResult

T8b949e/** Processes queue status updates from the radio. */
Tff7b72fun Td2a8ffhandleQueueStatusTb4b4b4(Te6edf3queueStatusTb4b4b4: Te6edf3QueueStatusTb4b4b4)

T8b949e/**
* Completes the strict routing response for [dataRequestId] when an active transport already dispatched that
* packet. Replies that arrive before dispatch are stale and ignored. The packet ID remains reserved until both the
* firmware queue stage and this routing stage are terminal.
*/
Tff7b72suspend Tff7b72fun Td2a8ffcompleteDispatchedResponseTb4b4b4(Te6edf3dataRequestIdTb4b4b4: Tffa657IntTb4b4b4, Te6edf3completeTb4b4b4: Tffa657BooleanTb4b4b4)

T8b949e/** Stops the packet queue. */
Tff7b72fun Td2a8ffstopPacketQueueTb4b4b4(Tb4b4b4)

T8b949e/**
* Re-arms the send-ACK timeout for every persisted packet still awaiting its routing ACK/NAK, so sends orphaned by
* a disconnect or app restart become retryable instead of showing as sending forever. Call once per connection,
* after the radio config is loaded.
*/
Tff7b72fun Td2a8ffrearmSendAckTimeoutsTb4b4b4(Tb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s